cmake_minimum_required(VERSION 3.19)
project(FacePreprocess)

set(CMAKE_CXX_STANDARD 17)

if (CMAKE_COMPILER_IS_GNUCXX)
    add_compile_options(-flto)
endif (CMAKE_COMPILER_IS_GNUCXX)

add_executable(FacePreprocess main.cpp data.cpp inc.h process.cpp)

find_package(OpenCV REQUIRED)
if (OpenCV_FOUND)
    include_directories(${OpenCV_INCLUDE_DIR})
    target_link_libraries(FacePreprocess ${OpenCV_LIBRARIES})
    target_link_libraries(FacePreprocess ${OpenCV_LIBRARIES})
endif ()

find_package(Threads REQUIRED)

include(FetchContent)
FetchContent_Declare(libfacedetection
        GIT_REPOSITORY https://github.com/ShiqiYu/libfacedetection.git
        GIT_TAG 779815459f2873a0b3b1b150b0d9711251f696cd
        )
if (CMAKE_COMPILER_IS_GNUCXX)
    set(libfacedetection_ENABLE_AVX2 ON)
endif (CMAKE_COMPILER_IS_GNUCXX)
FetchContent_MakeAvailable(libfacedetection)
include_directories(${libfacedetection_BINARY_DIR} ${libfacedetection_SOURCE_DIR}/src)

target_link_libraries(FacePreprocess Threads::Threads facedetection)